﻿app.controller('WeatherController', ['$scope', 'WeatherService', '$timeout', function ($scope, WeatherService, $timeout) {
    $scope.items = [];
    WeatherService.loadWeatherInfo().then(function (promise) {
        for (var i in promise) {
            var weatherObj = promise[i].data;
            $scope.items.push({
                city: weatherObj.name,
                conditions: weatherObj.weather,
                temp: weatherObj.main.temp
            });
        }
    }, function () {

    }, function (update) {
        $timeout(function () {
            $scope.$apply(function () {
                $scope.progress = update;
                $scope.progressText = ((update / 5) * 100).toString() + '%';
            });
        });
    });
}]);